package com.feeyo.groundservice.wifi.util

import com.feeyo.android.http.modules.NetworkObserver
import com.feeyo.android.util.FyLog

/**
 *作者：QLH on 2020-03-17
 *描述：复写的时候注意结果的传递，不要多次触发结果，子类复写onSuccess即可
 */
internal abstract class BaseObserver<T : Any> constructor(private val methodName:String = "", private val isLog: Boolean = true) :
    NetworkObserver<T>() {

    private val TAG = "BaseObserver---$methodName"
    override fun onError(e: Throwable) {
        if (isLog) {
            FyLog.e(TAG, "${e.message}---Cause by：${e.cause}")
        }
    }

    override fun onNext(t: T) {
        super.onNext(t)
        onSuccess(t)
    }

    override fun onComplete() {

    }
}